import request from '@/utils/Request'

// 机构列表-树形
export const listOrgTree = bId => {
  if (bId === undefined || bId === null) {
    bId = 0
  }
  return request({
    method: 'get',
    url: '/api/manage/org/list/tree/' + bId,
    params: {}
  })
}

// 机构列表
export const listOrg = data => {
  return request({
    method: 'get',
    url: '/api/manage/org/list',
    params: data
  })
}

// 新建机构
export const createOrg = data => {
  return request({
    method: 'post',
    url: '/api/manage/org/create',
    data: data
  })
}

// 更新机构
export const updateOrg = data => {
  return request({
    method: 'post',
    url: '/api/manage/org/update',
    data: data
  })
}
// 更新机构
export const updateOrgStatus = (orgId, status) => {
  return request({
    method: 'get',
    url: '/api/manage/org/' + orgId + '/status/' + status,
    params: {}
  })
}

// 保存机构
export const saveOrg = data => {
  return request({
    method: 'post',
    url: '/api/manage/org/save',
    data: data
  })
}

export const deleteOrg = bId => {
  return request({
    method: 'get',
    url: '/api/manage/org/delete/' + bId,
    params: {}
  })
}
